﻿
using SIG.Data;
using SIG.Data.UnitOfWork;
using SIG.Infrastructure.Cache;
using SIG.Infrastructure.Logging;
using SIG.Model.Identity;
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Text;


namespace SIG.Repository
{
    public class MenuRepository : Repository<Menu>,IMenuRepository
    {
     
        IMainBCUnitOfWork _unitOfWork;
        private ICacheService _cacheService;
        public MenuRepository(IMainBCUnitOfWork unitOfWork,  ICacheService cacheService)
            : base(unitOfWork)
        {
            if (unitOfWork == (IMainBCUnitOfWork)null)
                throw new ArgumentNullException("unitOfWork");
            if (cacheService == (ICacheService)null)
                throw new ArgumentNullException("cacheService");
            this._unitOfWork = unitOfWork;
            this._cacheService = cacheService;
        }

        //public IEnumerable<Menu> GetParentMenusWithChild()
        //{
        //    return this._dbset.Include("ChildMenus").Where(m => m.ParentId == null).OrderByDescending(m => m.Importance).ToList();
        //}
        //public IEnumerable<Menu> GetActivedMenusWithChild()
        //{
        //    return this._dbset.Include("ChildMenus").Where(m => m.ParentId==null && m.Active)
        //        .OrderByDescending(m => m.Importance).ToList();
        //}

        //public IEnumerable<Menu> GetUserMenus(IEnumerable<Role> roles)
        //{
        //    var rolesIds = roles.Select(r => r.Id).ToArray();
        //    return this.GetAllElements().Where(m => m.Roles.All(r => rolesIds.Contains(r.Id))).ToList();            

        //}
    }
}
